package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.travel.model.ProductBatch;
import com.eling.elcms.travel.model.ProductRuleDetail;
import com.eling.elcms.travel.model.view.ProductView;
import com.eling.elcms.travel.service.IProductRuleDetailManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class ProductRuleDetailController  extends BaseFormController{
	@Autowired
	private IProductRuleDetailManager productDetailManager;
	
	@RequestMapping("/api/productruledetail/query")
    @ResponseBody
    public List<ProductRuleDetail> query(@ModelAttribute ProductRuleDetail cond){
    	return productDetailManager.query(cond); 
    }
	
	@RequestMapping("/api/productruledetail/search")
    @ResponseBody
    public List<ProductRuleDetail> search(@ModelAttribute SearchCondition sc,@ModelAttribute ProductRuleDetail cond){
		sc.setQueryCondition(cond);
    	return productDetailManager.search(sc); 
    }
	
	@RequestMapping("/api/productruledetail/save")
    @ResponseBody
    public ProductRuleDetail save(@ModelAttribute ProductRuleDetail productDetail) {
		return productDetailManager.save(productDetail);
    }
	
	@RequestMapping("/api/productruledetail/{pkProductRuleDetail}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkProductDetail) {
		productDetailManager.remove(pkProductDetail);
	    return new Msg("删除成功");
	}
	
	@RequestMapping("/api/productruledetail/saveall")
    @ResponseBody
    public List<ProductRuleDetail> saveall(@ModelAttribute ProductView cond){
    	return productDetailManager.saveall(cond); 
    }
	
	@RequestMapping("/api/productruledetail/queryonly")
    @ResponseBody
    public List<ProductRuleDetail> queryonly(@ModelAttribute ProductRuleDetail cond){
    	return productDetailManager.queryonly(cond);
    }
	
	@RequestMapping("/api/productruledetail/{pkProductType}/querybatch")
	@ResponseBody
	public List<ProductBatch> queryBatch(@PathVariable Long pkProductType){
		return productDetailManager.queryBatch(pkProductType);
	}
}
